/*
 * @File name:
 * @Author: 1079161148@qq.com
 * @Version: V1.0
 * @Date: 2025-03-15 22:01:19
 * @Description:
 * Copyright (C) 2024-{year} Tsing Micro Technology Inc All rights reserved.
 */
import request from '@/utils/request'

export interface MomentItem {
  id: number | string
  content: string
  username: string
  avatar: string
  likes: number
  cover?: string
  images?: string[]
  createdAt: string
  location?: string
}

export interface MomentsListParams {
  page: number
  size: number
  category?: string
}

export interface MomentsListResponse {
  code: number
  data: {
    list: MomentItem[]
    total: number
    hasMore: boolean
  }
  message: string
}

// 获取动态列表
export function getMomentsList(params: MomentsListParams) {
  return request.get<MomentsListResponse>('/moments', { params })
}

// 获取动态详情
export function getMomentDetail(id: string | number) {
  return request.get<{ code: number; data: MomentItem; message: string }>(`/moments/${id}`)
}

// 点赞动态
export function likeMoment(id: string | number) {
  return request.post<{ code: number; message: string }>(`/moments/${id}/like`)
}

// 取消点赞
export function unlikeMoment(id: string | number) {
  return request.post<{ code: number; message: string }>(`/moments/${id}/unlike`)
}
